package o;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.core.app.NotificationCompat;
import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appgallery.packagemanager.api.bean.ManagerTask;
import com.huawei.appmarket.service.deamon.bean.DownloadHistory;
import com.huawei.appmarket.service.installfail.InsFailActivityProtocol;
import com.huawei.appmarket.service.installfail.InsFailActivityProtocol.Request;
import com.huawei.appmarket.service.webview.base.jssdk.control.FullAppStatus;
import com.huawei.fastengine.fastview.download.install.PackageManagerConstants;
import com.huawei.fastengine.fastview.startFastappEngine.bean.RpkInfo;
import com.huawei.hms.framework.network.restclient.hianalytics.HianalyticsData;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.huawei.hwid.core.constants.HwAccountConstants;
import com.huawei.updatesdk.service.otaupdate.UpdateStatusCode.DialogButton;
import java.io.File;
import java.io.IOException;
import o.cof.a;
import o.dge.d;
import o.eaw.c;
import o.ewm.e;
import o.ewm.n;

public class dwq extends Handler {
    public static final Handler ˊ = new dwq(ContentManager.getInstant().getContext().getMainLooper());

    public dwq(Looper looper) {
        super(looper);
    }

    public void handleMessage(Message message) {
        Object obj = message.obj;
        if (obj instanceof ManagerTask) {
            ManagerTask managerTask = (ManagerTask) obj;
            int i = message.arg1;
            ContentManager.getInstant().getContext().sendBroadcast(new Intent(dvq.ˊ()));
            Logger.ˎ(PackageManagerConstants.TAG, "ComPkgProcHandler" + " status view type:" + i + ",pkg:" + managerTask.packageName);
            switch (i) {
                case 3:
                    ॱ(managerTask);
                    return;
                case 4:
                    ˊ(message, managerTask);
                    return;
                case 5:
                    ॱ(message, managerTask, i);
                    return;
                case 9:
                    ˏ(message, managerTask);
                    return;
                case 11:
                    ˏ(managerTask);
                    return;
                case 12:
                    i = message.arg2;
                    dsv.ॱ(managerTask.packageName, DialogButton.CONFIRM);
                    ˎ(i, managerTask);
                    return;
                default:
                    ॱ(i, managerTask.packageName);
                    return;
            }
        }
    }

    private void ॱ(ManagerTask managerTask) {
        dwn.ˊ(managerTask);
    }

    private void ˊ(Message message, ManagerTask managerTask) {
        int i = message.arg2;
        if (-1000001 != i) {
            ˎ(i, managerTask);
            dsv.ॱ(managerTask.packageName, DialogButton.CONFIRM);
            new eax(managerTask, i, false).start();
        }
    }

    private void ॱ(Message message, ManagerTask managerTask, int i) {
        ˋ(message, managerTask, i);
        ˎ(ContentManager.getInstant().getContext(), managerTask.packageName);
        ˋ(managerTask);
    }

    private void ˏ(ManagerTask managerTask) {
        FullAppStatus fullAppStatus = new FullAppStatus();
        fullAppStatus.ˊ(managerTask.packageName);
        fullAppStatus.appType_ = 4;
        enf.ˋ().ˊ(fullAppStatus);
        if (diu.ˊ().ˎ()) {
            eba.ˋ().ˏ(ContentManager.getInstant().getContext(), managerTask.packageName, managerTask.ॱॱ, 3, managerTask.ʻ, managerTask.ʽ);
            new eaw(managerTask.packageName, c.COMMAND_CHK_3RD_INSTALL_APP_UPDATE).start();
        }
    }

    private void ˏ(Message message, ManagerTask managerTask) {
        int i = message.arg2;
        if (1000001 != i) {
            ˎ(managerTask, i);
        }
        ll.ˏ(ContentManager.getInstant().getContext()).ˋ(new Intent("com.huawei.appmarket.support.pm.PackageViewStatusManager.message.change"));
        ess.ˊ(i, managerTask);
    }

    private void ˋ(ManagerTask managerTask) {
        if (managerTask.ᐝ == 1 && managerTask.ʼ) {
            ced.ˎ(ContentManager.getInstant().getContext(), managerTask.packageName, dwn.ˎ(managerTask));
        }
    }

    private void ˋ(Message message, ManagerTask managerTask, int i) {
        int i2 = 2;
        if (!((message.arg2 == 1 ? 1 : null) == null || managerTask.apkInfos == null)) {
            for (a aVar : managerTask.apkInfos) {
                if ("base".equals(aVar.ˏ) && (aVar.ॱ == 0 || aVar.ॱ == 1)) {
                    try {
                        String canonicalPath = new File(aVar.ˎ).getCanonicalPath();
                        Intent intent = new Intent(epx.c.ˋ);
                        intent.putExtra(epx.c.ˊ, canonicalPath);
                        ll.ˏ(ContentManager.getInstant().getContext()).ˋ(intent);
                    } catch (IOException e) {
                        Logger.ˋ("ComPkgProcHandler", "can not getCanonicalPath");
                    }
                }
            }
        }
        eba ˋ = eba.ˋ();
        Context ˋ2 = ContentManager.getInstant().getContext();
        String str = managerTask.packageName;
        Object obj = managerTask.ॱॱ;
        if (managerTask.ᐝ != 2) {
            i2 = 1;
        }
        ˋ.ˏ(ˋ2, str, obj, i2, managerTask.ʻ);
    }

    private void ॱ(int i, String str) {
        switch (i) {
            case 10:
                eao ˎ = eap.ˎ(str);
                if (ˎ != null) {
                    dsl.ˊ(ˎ.ॱ(), ˎ.ˎ(), ˎ.ˏ(), 0, coc.NORMAL);
                    eap.ˎ(ˎ.ॱ(), ˎ.ˋ());
                    eap.ˊ(ˎ.ॱ());
                    return;
                }
                return;
            default:
                return;
        }
    }

    private void ˎ(int i, ManagerTask managerTask) {
        if (managerTask != null && managerTask.mode == 1) {
            dwo o_dwo = null;
            if (managerTask.ॱॱ instanceof SessionDownloadTask) {
                SessionDownloadTask sessionDownloadTask = (SessionDownloadTask) managerTask.ॱॱ;
                Logger.ˎ("ComPkgProcHandler", "DownloadTask notification install failed!!!!!!" + "packageName:" + managerTask.packageName + ",Name:" + sessionDownloadTask.ʿ() + ",icon:" + sessionDownloadTask.ˎˎ() + ",id:" + sessionDownloadTask.ʾ());
                o_dwo = new dwo(sessionDownloadTask.ʿ(), sessionDownloadTask.ˊˊ(), sessionDownloadTask.ˎˎ());
            } else if (managerTask.ॱॱ instanceof cog) {
                cog o_cog = (cog) managerTask.ॱॱ;
                Logger.ˎ("ComPkgProcHandler", "InstallExtraParam notification install failed!!!!!!" + "packageName:" + managerTask.packageName + ",Name:" + o_cog.ˊ() + ",icon:" + o_cog.ˎ() + ",id:" + o_cog.ˏ());
                o_dwo = new dwo(o_cog.ˊ(), managerTask.packageName, o_cog.ˎ());
            } else if (managerTask.ॱॱ instanceof DownloadHistory) {
                DownloadHistory downloadHistory = (DownloadHistory) managerTask.ॱॱ;
                Logger.ˎ("ComPkgProcHandler", "InstallExtraParam notification install failed!!!!!!" + "packageName:" + managerTask.packageName + ",Name:" + downloadHistory.ˏॱ() + ",icon:" + downloadHistory.ˊॱ());
                o_dwo = new dwo(downloadHistory.ˏॱ(), managerTask.packageName, downloadHistory.ˊॱ());
            }
            ॱ(ContentManager.getInstant().getContext(), i, o_dwo, managerTask);
        }
    }

    private void ˎ(Context context, String str) {
        eap.ˋ(str);
        eap.ˊ(str);
        ll.ˏ(context).ˋ(new Intent("com.huawei.appmarket.support.pm.PackageViewStatusManager.message.change"));
    }

    private void ˎ(ManagerTask managerTask, int i) {
        if (managerTask.ॱॱ != null && (managerTask.ॱॱ instanceof coe)) {
            CharSequence charSequence;
            coe o_coe = (coe) managerTask.ॱॱ;
            String string = ContentManager.getInstant().getContext().getString(ˏ(i));
            if (dof.ˋ(o_coe.ॱ)) {
                Object obj = string;
            } else {
                charSequence = "[" + o_coe.ॱ + "]" + string;
            }
            evk.ˋ(ContentManager.getInstant().getContext(), charSequence, 0).ˋ();
        }
    }

    private void ॱ(Context context, int i, dwo o_dwo, ManagerTask managerTask) {
        if (o_dwo != null) {
            dgh.onEvent(new d(context, n.ᶥ).ˏ(o_dwo.ˎ() + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + i + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + RpkInfo.VERSIONCODE + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + "hash" + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + "reason").ˋ());
            evk.ˏ(context.getString(n.ꓸˎ));
            NotificationCompat.d dVar = new NotificationCompat.d(ContentManager.getInstant().getContext());
            dVar.ˊ(false);
            dVar.ˊ(e.ॱ);
            dVar.ˎ(ˎ(context, o_dwo.ˊ(), o_dwo.ˎ(), i, o_dwo.ॱ(), managerTask.ˊॱ, managerTask.ͺ));
            dVar.ˏ(o_dwo.ˎ() + ContentManager.getInstant().getContext().getString(n.ʻˌ));
            dVar.ˊ(context.getString(n.ⵗ) + eap.ˎ().ˏ(i, context));
            dVar.ˊ(0, 0, false);
            dVar.ˊ(false);
            dVar.ˏ(true);
            try {
                dkk.ˊ(dVar, 20160227, o_dwo.ˊ(), o_dwo.ॱ());
                ॱ(context, o_dwo.ˊ(), o_dwo.ˎ(), i, o_dwo.ॱ(), managerTask.ˊॱ, managerTask.ͺ);
            } catch (Throwable e) {
                Logger.ˋ("ComPkgProcHandler", "", e);
            }
        }
    }

    private int ˏ(int i) {
        int i2 = n.ˋᶫ;
        switch (i) {
            case -4:
                return n.ˋꜝ;
            case -3:
                return n.ˌʻ;
            case -2:
                return n.ˋᵎ;
            case -1:
                return n.ˋⁱ;
            default:
                return i2;
        }
    }

    private PendingIntent ˎ(Context context, String str, String str2, int i, String str3, String str4, String str5) {
        cjo insFailActivityProtocol = new InsFailActivityProtocol();
        Request request = new Request();
        request.ˏ(str2);
        request.ˋ(str);
        request.ˋ(i);
        request.ॱ(str3);
        request.ˊ(str5);
        request.ˎ(str4);
        insFailActivityProtocol.ॱ(request);
        return PendingIntent.getActivity(context, 20160227, new cjm("installfailed.activity", insFailActivityProtocol).ॱ(context), HwAccountConstants.FLAG_TRANS_NAVIGATION_BAR);
    }

    private void ॱ(Context context, String str, String str2, int i, String str3, String str4, String str5) {
        Intent intent = new Intent("com.huawei.appmarket.support.pm.PackageViewStatusManager.message.change");
        intent.putExtra("icon_url", str);
        intent.putExtra("app_name", str2);
        intent.putExtra(HianalyticsData.ERROR_CODE, i);
        intent.putExtra("pkgName", str3);
        intent.putExtra("conflicting_pkg", str4);
        intent.putExtra("conflicting_app_name", str5);
        ll.ˏ(context).ˋ(intent);
    }
}
